#include <stdint.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h> 
#include <stdlib.h>
#include <assert.h>
#include "app_platform/cntl_info.h"
#include "accountao.h"


using namespace erp::account::ao;

CPP_SELF_DEFINE_START
/**
*  请在这里增加自定义的成员变量和函数及其他内容，否则无法合并代码
**/
#include "erp/account/to/businessunitsddoconvpo.h"
#include "erp/account/to/businessunitsfilterddoconvpo.h"
#include "erp/account/po/businessunitspo_account.h"
#include "erp/account/po/businessunitsfilterpo_account.h"
#include "erp/comm/erp_errno_define.h"
#include "erp/comm/erp_macro_define.h"


using namespace erp::account::po;
using namespace erp::account::ddo;
using namespace erp::account::to;
using namespace erp::comm;
using namespace c2cent::library::wwlog;
using namespace c2cent::library::wtimeelf;

CPP_SELF_DEFINE_END

/**
 *构建函数
 */
CAccountAo::CAccountAo(enum DeployMethod method)
{
}

/**
 *析构函数
 */
CAccountAo::~CAccountAo()
{
}


/**
 *每一次服务请求时，container都会调用此方法来清空数据
 */
void  CAccountAo::Reset()
{
}


int  CAccountAo::Initialize(IUserDefineCntl* pCntl)
{
	int iRet = 0;

    uint32_t dwLogSwitch=WLOG_OPEN|WLOG_KEY_OPEN|WLOG_ERR_OPEN;

    uint32_t dwCanLogRemote = 0;
    std::string strLogModule="ao_cooperator";
    std::set<uint32_t> setUseCache;

    std::cout<<"File:"<<__FILE__<<" Complie Date: "<<__DATE__<<" "<<__TIME__<<std::endl;

    GetUintConfig(LogSwitch);
    GetStringConfig(LogModule);
    GetUintConfig(CanLogRemote);

    // 初始化日志
    if( C2C_WWLOG->QuickInitForAPP2(strLogModule.c_str(),B2B2CWW_LOG_APP_FILE_PATH, dwCanLogRemote, dwLogSwitch)!= 0)
    {
        std::cerr << "C2C_WWLOG->QuickInitForAPP2 Failed" << std::endl;
        return -1;
    }
    C2C_WW_LOG("C2C_WWLOG->QuickInitForAPP2 OK!");

	return iRet;
}


/**
 *
 * 添加/修改来往单位；传入来往单位SysNo不为0时则进行修改，反之则进行添加；
 *
 *@param String machineKey: 机器码，必填   [in]
 *@param String source: 调用来源，必填   [in]
 *@param uint32_t sceneId: 场景ID，必填   [in]
 *@param uint32_t option: 功能选项，扩展选填   [in]
 *@param BusinessUnitsPo businessUnitsPo: 分支机构PO，必填   [in]
 *@param String inReserve: 请求保留字   [in]
 *@param String errmsg: 错误信息  	[out]
 *@param uint64_t SysNo: 返回相应的SysNo  	[out]
 *@param String outReserve: 返回保留字   	[out]
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CAccountAo::ModifyBusinessUnits(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				uint32_t dwOption,
				const erp::account::po::CBusinessUnitsPo& oBusinessUnitsPo,
				const std::string& strInReserve,
				std::string& strErrmsg,
				uint64_t& ddwSysNo,
				std::string& strOutReserve
	)
{
	uint32_t dwRet = 0;
	//TODO:业务代码
    C2C_WW_LOG("ModifyBusinessUnits %s OpUin:%u MachineKey:%s Source:%s SceneId:%u", __FUNCTION__,
    		rCntlInfo.getOperatorUin(), strMachineKey.c_str(), strSource.c_str(), dwSceneId);

    //打印性能日志的同时进行接口的itil上报
    //C2C_TIME_ELF_ITIL oWTimeElf(C2C_WWLOG,__FUNCTION__,&iRetCode,&s_oGetEmployee_Group);

    dwRet = CheckCommPara(rCntlInfo, strMachineKey, strSource, dwSceneId);

    if(dwRet!=0)
    {
    	C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
    	return dwRet;
    }

    dwRet = CheckBusinessUnits(oBusinessUnitsPo);

    if(dwRet!=0)
    {
    	C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
    	return dwRet;
    }

	erp::account::ddo::CBusinessUnitsDdo oBusinessUnitsDdo;

	CBusinessUnitsDdoConvCBusinessUnitsPo::Conv_CBusinessUnitsPo_To_CBusinessUnitsDdo(oBusinessUnitsPo, oBusinessUnitsDdo);
	
	dwRet = m_cAccountDaoStub4App.ModifyBusinessUnits(
			rCntlInfo,
			strMachineKey,
			strSource,
			dwSceneId,
			dwOption,
			oBusinessUnitsDdo,
			strInReserve,
			strErrmsg,
			ddwSysNo,
			strOutReserve);

	if(dwRet!=0)
	{
	    C2C_WW_LOG_ERR(dwRet,"ModifyBusinessUnits Failed! SceneId:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u ErrMsg:%s",
	    		dwSceneId,rCntlInfo.getOperatorUin(), strMachineKey.c_str(), strSource.c_str(), dwSceneId,strErrmsg.c_str());
	    C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
		return dwRet;
	}

	return dwRet;
}

/**
 *
 * 删除来往单位（逻辑）
 *
 *@param String machineKey: 机器码，必填   [in]
 *@param String source: 调用来源，必填   [in]
 *@param uint32_t sceneId: 场景ID，必填   [in]
 *@param uint32_t option: 功能选项，扩展选填   [in]
 *@param uint64_t businessUnitsSysNo: 需删除的来往单位的SysNo，必填   [in]
 *@param String inReserve: 请求保留字   [in]
 *@param String errmsg: 错误信息  	[out]
 *@param String outReserve: 返回保留字   	[out]
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CAccountAo::DeleteBusinessUnits(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				uint32_t dwOption,
				uint64_t ddwBusinessUnitsSysNo,
				const std::string& strInReserve,
				std::string& strErrmsg,
				std::string& strOutReserve
	)
{
	uint32_t dwRet = 0;
	//TODO:业务代码
    C2C_WW_LOG("DeleteBusinessUnits %s OpUin:%u MachineKey:%s Source:%s SceneId:%u", __FUNCTION__,
    		rCntlInfo.getOperatorUin(), strMachineKey.c_str(), strSource.c_str(), dwSceneId);

    //打印性能日志的同时进行接口的itil上报
    //C2C_TIME_ELF_ITIL oWTimeElf(C2C_WWLOG,__FUNCTION__,&iRetCode,&s_oGetEmployee_Group);

    dwRet=CheckCommPara(rCntlInfo, strMachineKey, strSource, dwSceneId);

    if(dwRet!=0)
    {
    	C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
    	return dwRet;
    }

	dwRet = m_cAccountDaoStub4App.DeleteBusinessUnits(
			rCntlInfo,
			strMachineKey,
			strSource,
			dwSceneId,
			dwOption,
			ddwBusinessUnitsSysNo,
			strInReserve,
			strErrmsg,
			strOutReserve);

	if(dwRet!=0)
	{
	    C2C_WW_LOG_ERR(dwRet,"DeleteBusinessUnits Failed! SceneId:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u ErrMsg:%s",
	    		dwSceneId,rCntlInfo.getOperatorUin(), strMachineKey.c_str(), strSource.c_str(), dwSceneId,strErrmsg.c_str());
	    C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
		return dwRet;
	}

	return dwRet;
}

/**
 *
 * 根据分支机构ID批量获取分支机构信息
 *
 *@param String machineKey: 机器码，必填   [in]
 *@param String source: 调用来源，必填   [in]
 *@param uint32_t sceneId: 场景ID，必填   [in]
 *@param uint32_t option: 功能选项，扩展选填   [in]
 *@param Set businessUnitsSysNo: 需获取的来往单位的SysNo，必填   [in]
 *@param String inReserve: 请求保留字   [in]
 *@param String errmsg: 错误信息  	[out]
 *@param Map errorCode: 获取失败的错误码 	[out]
 *@param Map errorMsg: 获取失败的错误信息 	[out]
 *@param Map businessUnitsPo: 获取成功的来往单位信息 	[out]
 *@param String outReserve: 返回保留字   	[out]
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CAccountAo::GetBusinessUnitsBySysNos(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				uint32_t dwOption,
				const std::set<uint64_t >& setBusinessUnitsSysNo,
				const std::string& strInReserve,
				std::string& strErrmsg,
				std::map<uint64_t,uint32_t >& mapErrorCode,
				std::map<uint64_t,std::string >& mapErrorMsg,
				std::map<uint64_t,erp::account::po::CBusinessUnitsPo >& mapBusinessUnitsPo,
				std::string& strOutReserve
	)
{
	uint32_t dwRet = 0;
	//TODO:业务代码

    C2C_WW_LOG("GetBusinessUnitsByIds %s OpUin:%u MachineKey:%s Source:%s SceneId:%u", __FUNCTION__,
    		rCntlInfo.getOperatorUin(), strMachineKey.c_str(), strSource.c_str(), dwSceneId);


    dwRet=CheckCommPara(rCntlInfo, strMachineKey, strSource, dwSceneId);

    if(dwRet!=0)
    {
    	C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
    	return dwRet;
    }

	std::map<uint64_t, erp::account::ddo::CBusinessUnitsDdo> mapBusinessUnitsDdo;

	dwRet = m_cAccountDaoStub4App.GetBusinessUnitsByIds(
			rCntlInfo,
			strMachineKey,
			strSource,
			dwSceneId,
			dwOption,
			setBusinessUnitsSysNo,
			strInReserve,
			strErrmsg,
			mapErrorCode,
			mapErrorMsg,
			mapBusinessUnitsDdo,
			strOutReserve);


	if(dwRet!=0)
	{
	    C2C_WW_LOG_ERR(dwRet,"GetBusinessUnitsByIds Failed! SceneId:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u ErrMsg:%s",
	    		dwSceneId,rCntlInfo.getOperatorUin(), strMachineKey.c_str(), strSource.c_str(), dwSceneId,strErrmsg.c_str());
	    C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
		return dwRet;
	}

    std::map<uint64_t, erp::account::ddo::CBusinessUnitsDdo>::const_iterator it = mapBusinessUnitsDdo.begin();
    for (; it != mapBusinessUnitsDdo.end(); it++)
    {
    	erp::account::po::CBusinessUnitsPo oBusinessUnitsPo;
    	CBusinessUnitsDdoConvCBusinessUnitsPo::Conv_CBusinessUnitsDdo_To_CBusinessUnitsPo((*it).second, oBusinessUnitsPo);
    	mapBusinessUnitsPo[(*it).first] = oBusinessUnitsPo;
    }

	return dwRet;
}

/**
 *
 * 根据过滤条件查询来往单位列表信息
 *
 *@param String machineKey: 机器码，必填   [in]
 *@param String source: 调用来源，必填   [in]
 *@param uint32_t sceneId: 场景ID，必填   [in]
 *@param uint32_t option: 功能选项，扩展选填   [in]
 *@param BusinessUnitsFilterPo filter: 过滤器，必填   [in]
 *@param String inReserve: 请求保留字   [in]
 *@param String errmsg: 错误信息  	[out]
 *@param uint32_t total: 分支机构总数 	[out]
 *@param Vector businessUnitsPo: 分支机构列表信息 	[out]
 *@param String outReserve: 返回保留字   	[out]
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CAccountAo::GetBusinessUnitsByFilter(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				uint32_t dwOption,
				const erp::account::po::CBusinessUnitsFilterPo& oFilter,
				const std::string& strInReserve,
				std::string& strErrmsg,
				uint32_t& dwTotal,
				std::vector<erp::account::po::CBusinessUnitsPo >& vecBusinessUnitsPo,
				std::string& strOutReserve
	)
{
	uint32_t dwRet = 0;
	//TODO:业务代码
    C2C_WW_LOG("GetBusinessUnitsByIds %s OpUin:%u MachineKey:%s Source:%s SceneId:%u", __FUNCTION__,
    		rCntlInfo.getOperatorUin(), strMachineKey.c_str(), strSource.c_str(), dwSceneId);

    dwRet = CheckCommPara(rCntlInfo, strMachineKey, strSource, dwSceneId);

    if(dwRet != 0)
    {
    	C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
    	return dwRet;
    }

    dwRet=CheckBusinessUnitsFilter(oFilter);

    if(dwRet != 0)
    {
    	C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
    	return dwRet;
    }

    CBusinessUnitsFilterDdo oBusinessUnitsFilterDdo;
    CBusinessUnitsFilterDdoConvCBusinessUnitsFilterPo::Conv_CBusinessUnitsFilterPo_To_CBusinessUnitsFilterDdo(oFilter, oBusinessUnitsFilterDdo);

    std::vector<CBusinessUnitsDdo> vecBusinessUnitsDdo;

	dwRet = m_cAccountDaoStub4App.GetBusinessUnitsByFilter(
			rCntlInfo,
			strMachineKey,
			strSource,
			dwSceneId,
			dwOption,
			oBusinessUnitsFilterDdo,
			strInReserve,
			strErrmsg,
			dwTotal,
			vecBusinessUnitsDdo,
			strOutReserve);


	if(dwRet!=0)
	{
	    C2C_WW_LOG_ERR(dwRet,"GetBusinessUnitsByFilter Failed! SceneId:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u ErrMsg:%s",
	    		dwSceneId,rCntlInfo.getOperatorUin(), strMachineKey.c_str(), strSource.c_str(), dwSceneId,strErrmsg.c_str());
	    C2C_WW_LOG_LAST_ERR_LOG(strErrmsg);
		return dwRet;
	}

    std::vector<CBusinessUnitsDdo>::const_iterator it = vecBusinessUnitsDdo.begin();
    for (; it != vecBusinessUnitsDdo.end(); it++)
    {
    	CBusinessUnitsPo oBusinessUnitsPo;
    	CBusinessUnitsDdoConvCBusinessUnitsPo::Conv_CBusinessUnitsDdo_To_CBusinessUnitsPo((*it), oBusinessUnitsPo);
    	vecBusinessUnitsPo.push_back(oBusinessUnitsPo);
    }

	return dwRet;
}

uint32_t CAccountAo::CheckCommPara(
		const CCntlInfo& rCntlInfo,
		const std::string& strMachineKey,
		const std::string& strSource,
		uint32_t dwSceneId)
{
	int32_t iRetCode = 0;

	if(strMachineKey.empty())
	{
		iRetCode=ERR_ERP_COMMON_MACHINEKEY_INVALID;
		C2C_WW_LOG_ERR(iRetCode,"MachineKey Error! MachineKey:%s OpUin:%u  Source:%s SceneId:%u",
				strMachineKey.c_str(),rCntlInfo.getOperatorUin(), strSource.c_str(), dwSceneId);
		return iRetCode;
	}

	if(strSource.empty())
	{
		iRetCode=ERR_ERP_COMMON_SOURCE_INVALID;
		C2C_WW_LOG_ERR(iRetCode,"Source Error! MachineKey:%s OpUin:%u  Source:%s SceneId:%u",
				strMachineKey.c_str(),rCntlInfo.getOperatorUin(), strSource.c_str(), dwSceneId);
		return iRetCode;
	}

	if(dwSceneId==0)
	{
		iRetCode=ERR_ERP_COMMON_SCENEID_INVALID;
		C2C_WW_LOG_ERR(iRetCode,"SceneId Error! MachineKey:%s OpUin:%u  Source:%s SceneId:%u",
				strMachineKey.c_str(),rCntlInfo.getOperatorUin(), strSource.c_str(), dwSceneId);
		return iRetCode;
	}

	return iRetCode;
}

uint32_t CAccountAo::CheckBusinessUnitsFilter(const erp::account::po::CBusinessUnitsFilterPo& oBusinessUnitsFilter)
{
	int32_t iRetCode = 0;

	/*
	if(oEmployeeFilter.IsPageSizeSet()&&s_dwPageSizeLimit<oEmployeeFilter.GetPageSize())
	{
		iRetCode=ERR_ERP_EMPLOYEE_PAGESIZE;
		C2C_WW_LOG_ERR(iRetCode,"PageSize Error! PageSize:%u MaxLimit:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u",
				oEmployeeFilter.GetPageSize(),s_dwPageSizeLimit,m_dwOperatorUin, m_strMachineKey.c_str(), m_strSource.c_str(), m_dwSceneId);
		return iRetCode;
	}

	if(oEmployeeFilter.IsIdListSet()&&s_dwPageSizeLimit<oEmployeeFilter.GetIdList().size())
	{
		iRetCode=ERR_ERP_EMPLOYEE_PAGESIZE;
		C2C_WW_LOG_ERR(iRetCode,"IdListSize Error! IdListSize:%zu MaxLimit:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u",
				oEmployeeFilter.GetIdList().size(),s_dwPageSizeLimit,m_dwOperatorUin, m_strMachineKey.c_str(), m_strSource.c_str(), m_dwSceneId);
		return iRetCode;
	}

	if(oEmployeeFilter.IsOrderTypeSet()&&
			(oEmployeeFilter.GetOrderType()>ORDERTYPE_MAX))
	{
		iRetCode=ERR_ERP_EMPLOYEE_ORDERTYPE;
		C2C_WW_LOG_ERR(iRetCode,"OrderType Error! OrderType:%u MinLimit:%u MaxLimit:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u",
				oEmployeeFilter.GetOrderType(),ORDERTYPE_MIN,ORDERTYPE_MAX,m_dwOperatorUin, m_strMachineKey.c_str(), m_strSource.c_str(), m_dwSceneId);
		return iRetCode;
	}

	if(oEmployeeFilter.IsEmployeeEnglishNameSet()&&LENGTH_ENGLISHNAME<oEmployeeFilter.GetEmployeeEnglishName().size())
	{
		iRetCode=ERR_ERP_EMPLOYEE_ENGLISHNAMESIZE;
		C2C_WW_LOG_ERR(iRetCode,"EnglishName Error! EnglishName:%s EnglishNameLimitSize:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u",
			   oEmployeeFilter.GetEmployeeEnglishName().c_str(),LENGTH_ENGLISHNAME,m_dwOperatorUin, m_strMachineKey.c_str(), m_strSource.c_str(), m_dwSceneId);
		return iRetCode;
	}

	if(oEmployeeFilter.IsEmployeeNameSet()&&LENGTH_NAME<oEmployeeFilter.GetEmployeeName().size())
	{
		iRetCode=ERR_ERP_EMPLOYEE_NAMESIZE;
		C2C_WW_LOG_ERR(iRetCode,"Name Error! Name:%s NameLimitSize:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u",
				  oEmployeeFilter.GetEmployeeName().c_str(),LENGTH_NAME,m_dwOperatorUin, m_strMachineKey.c_str(), m_strSource.c_str(), m_dwSceneId);
		return iRetCode;
	}

	if(oEmployeeFilter.IsEmployeeStatusSet()&&
				(*oEmployeeFilter.GetEmployeeStatus().rbegin()>STATUS_MAX))
	{
		iRetCode=ERR_ERP_EMPLOYEE_STATUS;
		C2C_WW_LOG_ERR(iRetCode,"STATUS Error! STATUS:%u MinLimit:%u MaxLimit:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u",
				*oEmployeeFilter.GetEmployeeStatus().rbegin(),STATUS_MIN,STATUS_MAX,m_dwOperatorUin, m_strMachineKey.c_str(), m_strSource.c_str(), m_dwSceneId);
		return iRetCode;
	}

	*/

	return iRetCode;
}

uint32_t CAccountAo::CheckBusinessUnits(const erp::account::po::CBusinessUnitsPo& oBusinessUnitsPo)
{
	int32_t iRetCode = 0;

	/*
	if(oEmployee.IsEmployeeEnglishNameSet()&&LENGTH_ENGLISHNAME<oEmployee.GetEmployeeEnglishName().size())
	{
		iRetCode=ERR_ERP_EMPLOYEE_ENGLISHNAMESIZE;
		C2C_WW_LOG_ERR(iRetCode,"EnglishName Error! EnglishName:%s EnglishNameLimitSize:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u",
				oEmployee.GetEmployeeEnglishName().c_str(),LENGTH_ENGLISHNAME,m_dwOperatorUin, m_strMachineKey.c_str(), m_strSource.c_str(), m_dwSceneId);
		return iRetCode;
	}

	if(oEmployee.IsEmployeeNameSet()&&LENGTH_NAME<oEmployee.GetEmployeeName().size())
	{
		iRetCode=ERR_ERP_EMPLOYEE_NAMESIZE;
		C2C_WW_LOG_ERR(iRetCode,"Name Error! Name:%s NameLimitSize:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u",
				oEmployee.GetEmployeeName().c_str(),LENGTH_NAME,m_dwOperatorUin, m_strMachineKey.c_str(), m_strSource.c_str(), m_dwSceneId);
		return iRetCode;
	}

	if(oEmployee.IsEmployeeSexSet()&&oEmployee.GetEmployeeSex()>SEX_MAX)
	{
		iRetCode=ERR_ERP_EMPLOYEE_SEX;
		C2C_WW_LOG_ERR(iRetCode,"SEX Error! Sex:%u MinLimit:%u MaxLimit:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u",
				oEmployee.GetEmployeeSex(),SEX_MIN,SEX_MAX,m_dwOperatorUin, m_strMachineKey.c_str(), m_strSource.c_str(), m_dwSceneId);
		return iRetCode;
	}

	if(oEmployee.IsEmployeeStatusSet()&&oEmployee.GetEmployeeStatus()>STATUS_MAX)
	{
		iRetCode=ERR_ERP_EMPLOYEE_STATUS;
		C2C_WW_LOG_ERR(iRetCode,"STATUS Error! STATUS:%u MinLimit:%u MaxLimit:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u",
				oEmployee.GetEmployeeStatus(),STATUS_MIN,STATUS_MAX,m_dwOperatorUin, m_strMachineKey.c_str(), m_strSource.c_str(), m_dwSceneId);
		return iRetCode;
	}

	if(oEmployee.IsEmployeeTypeSet()&&oEmployee.GetEmployeeType()>TYPE_MAX)
	{
		iRetCode=ERR_ERP_EMPLOYEE_TYPE;
		C2C_WW_LOG_ERR(iRetCode,"TYPE Error! Type:%u MinLimit:%u MaxLimit:%u OpUin:%u MachineKey:%s Source:%s SceneId:%u",
				oEmployee.GetEmployeeStatus(),TYPE_MIN,TYPE_MAX,m_dwOperatorUin, m_strMachineKey.c_str(), m_strSource.c_str(), m_dwSceneId);
		return iRetCode;
	}

	if((oEmployee.GetEmployeePropertyInclude()&(~s_bitsetValidPropertyBit)).to_ulong()>0)
	{
		iRetCode=ERR_ERP_EMPLOYEE_PROPERTY_OUTRANGE;
		C2C_WW_LOG_ERR(iRetCode,"Property Out Range Error! Property:%s PropertyLimit:%s OpUin:%u MachineKey:%s Source:%s SceneId:%u",
				oEmployee.GetEmployeePropertyInclude().to_string().c_str(),s_bitsetValidPropertyBit.to_string().c_str(),m_dwOperatorUin, m_strMachineKey.c_str(), m_strSource.c_str(), m_dwSceneId);
		return iRetCode;
	}
	*/

	return iRetCode;
}

/**
 *
 * 添加/修改职员；传入来往单位SysNo不为0时则进行修改，反之则进行添加；
 *
 *@param String machineKey: 机器码，必填   [in]				
 *@param String source: 调用来源，必填   [in]				
 *@param uint32_t sceneId: 场景ID，必填   [in]				
 *@param uint32_t option: 功能选项，扩展选填   [in]				
 *@param EmployeePo employeePo: 职员PO，必填   [in]				
 *@param String inReserve: 请求保留字   [in]				
 *@param String errmsg: 错误信息  	[out]	
 *@param uint64_t SysNo: 返回相应的SysNo  	[out]	
 *@param String outReserve: 返回保留字   	[out]	
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CAccountAo::ModifyEmployee(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				uint32_t dwOption,
				const erp::account::po::CEmployeePo& oEmployeePo,
				const std::string& strInReserve,
				std::string& strErrmsg,
				uint64_t& ddwSysNo,
				std::string& strOutReserve
	)
{
	uint32_t dwRet = 0;
	//TODO:业务代码
	
	return dwRet;
}

/**
 *
 * 删除职员（逻辑）
 *
 *@param String machineKey: 机器码，必填   [in]				
 *@param String source: 调用来源，必填   [in]				
 *@param uint32_t sceneId: 场景ID，必填   [in]				
 *@param uint32_t option: 功能选项，扩展选填   [in]				
 *@param uint64_t employeeSysNo: 需删除的职员的SysNo，必填   [in]				
 *@param String inReserve: 请求保留字   [in]				
 *@param String errmsg: 错误信息  	[out]	
 *@param String outReserve: 返回保留字   	[out]	
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CAccountAo::DeleteEmployee(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				uint32_t dwOption,
				uint64_t ddwEmployeeSysNo,
				const std::string& strInReserve,
				std::string& strErrmsg,
				std::string& strOutReserve
	)
{
	uint32_t dwRet = 0;
	//TODO:业务代码
	
	return dwRet;
}

/**
 *
 * 根据职员ID批量获取职员信息
 *
 *@param String machineKey: 机器码，必填   [in]				
 *@param String source: 调用来源，必填   [in]				
 *@param uint32_t sceneId: 场景ID，必填   [in]				
 *@param uint32_t option: 功能选项，扩展选填   [in]				
 *@param Set employeeSysNo: 需获取的职员的SysNo，必填   [in]				
 *@param String inReserve: 请求保留字   [in]				
 *@param String errmsg: 错误信息  	[out]	
 *@param Map errorCode: 获取失败的错误码 	[out]	
 *@param Map errorMsg: 获取失败的错误信息 	[out]	
 *@param Map employeePo: 获取成功的来往单位信息 	[out]	
 *@param String outReserve: 返回保留字   	[out]	
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CAccountAo::GetEmployeeBySysNos(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				uint32_t dwOption,
				const std::set<uint64_t >& setEmployeeSysNo,
				const std::string& strInReserve,
				std::string& strErrmsg,
				std::map<uint64_t,uint32_t >& mapErrorCode,
				std::map<uint64_t,std::string >& mapErrorMsg,
				std::map<uint64_t,erp::account::po::CEmployeePo >& mapEmployeePo,
				std::string& strOutReserve
	)
{
	uint32_t dwRet = 0;
	//TODO:业务代码
	
	return dwRet;
}

/**
 *
 * 根据过滤条件查询职员列表信息
 *
 *@param String machineKey: 机器码，必填   [in]				
 *@param String source: 调用来源，必填   [in]				
 *@param uint32_t sceneId: 场景ID，必填   [in]				
 *@param uint32_t option: 功能选项，扩展选填   [in]				
 *@param EmployeeFilterPo filter: 过滤器，必填   [in]				
 *@param String inReserve: 请求保留字   [in]				
 *@param String errmsg: 错误信息  	[out]	
 *@param uint32_t total: 职员总数 	[out]	
 *@param Vector businessUnitsPo: 职员列表信息 	[out]	
 *@param String outReserve: 返回保留字   	[out]	
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CAccountAo::GetEmployeeByFilter(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				uint32_t dwOption,
				const erp::account::po::CEmployeeFilterPo& oFilter,
				const std::string& strInReserve,
				std::string& strErrmsg,
				uint32_t& dwTotal,
				std::vector<erp::account::po::CEmployeePo >& vecBusinessUnitsPo,
				std::string& strOutReserve
	)
{
	uint32_t dwRet = 0;
	//TODO:业务代码
	
	return dwRet;
}

/**
 *
 * 根据主键查询信用额度
 *
 *@param String machineKey: 机器码，必填   [in]				
 *@param String source: 调用来源，必填   [in]				
 *@param uint32_t sceneId: 场景ID，必填   [in]				
 *@param uint32_t option: 功能选项，扩展选填   [in]				
 *@param uint64_t branchSysNo: 分支机构SysNo，必填   [in]				
 *@param uint64_t businessUnitsSysNo: 往来单位SysNo，必填   [in]				
 *@param String inReserve: 请求保留字   [in]				
 *@param String errmsg: 错误信息  	[out]	
 *@param CustomerCreditPo customerCreditPo: 信用额度信息 	[out]	
 *@param String outReserve: 返回保留字   	[out]	
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CAccountAo::GetCustomerCredit(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				uint32_t dwOption,
				uint64_t ddwBranchSysNo,
				uint64_t ddwBusinessUnitsSysNo,
				const std::string& strInReserve,
				std::string& strErrmsg,
				erp::account::po::CCustomerCreditPo& oCustomerCreditPo,
				std::string& strOutReserve
	)
{
	uint32_t dwRet = 0;
	//TODO:业务代码
	
	return dwRet;
}

/**
 *
 * 添加/修改信用额度；传入组合主键往来单位SysNo和分支机构SysNo
 *
 *@param String machineKey: 机器码，必填   [in]				
 *@param String source: 调用来源，必填   [in]				
 *@param uint32_t sceneId: 场景ID，必填   [in]				
 *@param uint32_t option: 功能选项，扩展选填   [in]				
 *@param CustomerCreditPo customerCreditPo: 职员PO，必填   [in]				
 *@param String inReserve: 请求保留字   [in]				
 *@param String errmsg: 错误信息  	[out]	
 *@param String outReserve: 返回保留字   	[out]	
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CAccountAo::ModifyCustomerCredit(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				uint32_t dwOption,
				const erp::account::po::CCustomerCreditPo& oCustomerCreditPo,
				const std::string& strInReserve,
				std::string& strErrmsg,
				std::string& strOutReserve
	)
{
	uint32_t dwRet = 0;
	//TODO:业务代码
	
	return dwRet;
}

/**
 *
 * 添加/修改联系人；传入联系人SysNo不为0时则进行修改，反之则进行添加；
 *
 *@param String machineKey: 机器码，必填   [in]				
 *@param String source: 调用来源，必填   [in]				
 *@param uint32_t sceneId: 场景ID，必填   [in]				
 *@param uint32_t option: 功能选项，扩展选填   [in]				
 *@param ContactPo contactPo: 分支机构PO，必填   [in]				
 *@param String inReserve: 请求保留字   [in]				
 *@param String errmsg: 错误信息  	[out]	
 *@param uint64_t SysNo: 返回相应的SysNo  	[out]	
 *@param String outReserve: 返回保留字   	[out]	
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CAccountAo::ModifyContact(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				uint32_t dwOption,
				const erp::account::po::CContactPo& oContactPo,
				const std::string& strInReserve,
				std::string& strErrmsg,
				uint64_t& ddwSysNo,
				std::string& strOutReserve
	)
{
	uint32_t dwRet = 0;
	//TODO:业务代码
	
	return dwRet;
}

/**
 *
 * 删除联系人（逻辑）
 *
 *@param String machineKey: 机器码，必填   [in]				
 *@param String source: 调用来源，必填   [in]				
 *@param uint32_t sceneId: 场景ID，必填   [in]				
 *@param uint32_t option: 功能选项，扩展选填   [in]				
 *@param uint64_t contactSysNo: 需删除的联系人的SysNo，必填   [in]				
 *@param String inReserve: 请求保留字   [in]				
 *@param String errmsg: 错误信息  	[out]	
 *@param String outReserve: 返回保留字   	[out]	
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CAccountAo::DeleteContact(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				uint32_t dwOption,
				uint64_t ddwContactSysNo,
				const std::string& strInReserve,
				std::string& strErrmsg,
				std::string& strOutReserve
	)
{
	uint32_t dwRet = 0;
	//TODO:业务代码
	
	return dwRet;
}

/**
 *
 * 根据联系人SysNo批量获取联系人信息
 *
 *@param String machineKey: 机器码，必填   [in]				
 *@param String source: 调用来源，必填   [in]				
 *@param uint32_t sceneId: 场景ID，必填   [in]				
 *@param uint32_t option: 功能选项，扩展选填   [in]				
 *@param Set contactSysNo: 需获取的联系人的SysNo，必填   [in]				
 *@param String inReserve: 请求保留字   [in]				
 *@param String errmsg: 错误信息  	[out]	
 *@param Map errorCode: 获取失败的错误码 	[out]	
 *@param Map errorMsg: 获取失败的错误信息 	[out]	
 *@param Map contactPo: 获取成功的来往单位信息 	[out]	
 *@param String outReserve: 返回保留字   	[out]	
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CAccountAo::GetContactBySysNos(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				uint32_t dwOption,
				const std::set<uint64_t >& setContactSysNo,
				const std::string& strInReserve,
				std::string& strErrmsg,
				std::map<uint64_t,uint32_t >& mapErrorCode,
				std::map<uint64_t,std::string >& mapErrorMsg,
				std::map<uint64_t,erp::account::po::CContactPo >& mapContactPo,
				std::string& strOutReserve
	)
{
	uint32_t dwRet = 0;
	//TODO:业务代码
	
	return dwRet;
}

/**
 *
 * 根据过滤条件查询联系人信息
 *
 *@param String machineKey: 机器码，必填   [in]				
 *@param String source: 调用来源，必填   [in]				
 *@param uint32_t sceneId: 场景ID，必填   [in]				
 *@param uint32_t option: 功能选项，扩展选填   [in]				
 *@param ContactFilterPo filter: 过滤器，必填   [in]				
 *@param String inReserve: 请求保留字   [in]				
 *@param String errmsg: 错误信息  	[out]	
 *@param uint32_t total: 分支机构总数 	[out]	
 *@param Vector contactPo: 分支机构列表信息 	[out]	
 *@param String outReserve: 返回保留字   	[out]	
 *
 *@return  uint32_t : 0(成功) 其它失败
 *
 */
uint32_t CAccountAo::GetContactByFilter(
				const CCntlInfo& rCntlInfo,
				const std::string& strMachineKey,
				const std::string& strSource,
				uint32_t dwSceneId,
				uint32_t dwOption,
				const erp::account::po::CContactFilterPo& oFilter,
				const std::string& strInReserve,
				std::string& strErrmsg,
				uint32_t& dwTotal,
				std::vector<erp::account::po::CContactPo >& vecContactPo,
				std::string& strOutReserve
	)
{
	uint32_t dwRet = 0;
	//TODO:业务代码
	
	return dwRet;
}
